package com.wave.wavesystem.server.wrapper;

import com.wave.wavesystem.business.mapper.UserMapper;
import com.wave.wavesystem.business.pojo.entity.UserEntity;
import com.wave.wavesystem.server.pojo.entity.ArticleEntity;
import com.wave.wavesystem.server.pojo.vo.article.ArticleVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import wave.common.pojo.entity.BaseWrapper;

import javax.annotation.Resource;

/**
 * @author 夕下风波
 * @date 2025-02-23 14:10
 * @description 文章包装类
 */
@Component
public class ArticleWrapper extends BaseWrapper<ArticleEntity, ArticleVO> {

    @Resource
    private UserMapper userMapper;

    @Override
    public ArticleVO entityVO(ArticleEntity entity) {
        ArticleVO vo = new ArticleVO();
        BeanUtils.copyProperties(entity,vo);
        UserEntity author = userMapper.selectOneById(entity.getAuthorId());
        vo.setAuthorName(author.getNickname());
        return vo;
    }

}
